<%--
  Created by IntelliJ IDEA.
  User: notyoukennk
  Date: 2022/12/16
  Time: 16:37
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: notyoukennk
  Date: 2022/11/27
  Time: 21:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.*" %>
<%@ page import="ProjectManagement.DobConn" %>
<%@ page language="java" import="java.util.*,com.spm.pojo.Student"
         pageEncoding="utf-8"%>
<%@ page import="com.spm.service.impl.*"%>
<html>
<head>
  <title>选课确认</title>
  <style>
    #customers {
      font-family: Arial, Helvetica, sans-serif;
      border-collapse: collapse;
      width: 100%;
    }

    #customers td, #customers th {
      border: 1px solid #ddd;
      padding: 8px;
    }

    #customers tr:nth-child(even){background-color: #f2f2f2;}

    #customers tr:hover {background-color: #ddd;}

    #customers th {
      padding-top: 12px;
      padding-bottom: 12px;
      text-align: left;
      background-color: #1f1b1a;
      color: white;
    }

  </style>
</head>

<body>
<table id="customers">
  <tr>
    <th>学号</th>
    <th>姓名</th>
    <th>班级</th>
    <th>操作</th>
  </tr>
  <%
      try {
          String courseid=(String) session.getAttribute("courseid");
          ArrayList<String > arr=new ArrayList<>();
          Connection conn = DobConn.getConn();
          Statement stat = conn.createStatement();
          String sql1 = "SELECT * FROM Student_R_Course where Cno="+courseid+" order by Sid asc";
          ResultSet rs = null;
          rs = stat.executeQuery(sql1);
          while(rs.next()){
             String Sid1=rs.getString("Sid");
             arr.add(Sid1);
          }
          for (int i=0;i<arr.size();i++){
              String str=arr.get(i);
              String sql2 = "SELECT * FROM Student where Sid="+str+" order by Sid asc";
              ResultSet rs1 = null;
              rs1 = stat.executeQuery(sql2);
              while(rs1.next()){
                  String Sid = rs1.getString("Sid");
                  String Sname=rs1.getString("Sname");
                  String Sclass = rs1.getString("Sclass");
                  out.print("<tr>\n" +
                          "        <td>"+Sid+"</td>\n" +
                          "        <td>"+Sname+"</td>\n" +
                          "        <td>"+Sclass+"</td>\n" +
                          "        <td ><a href='GradeEnter?method=enter'>录入成绩</a>\n" +
                          "        </td>\n" +
                          "    </tr>");
              }
          }

      } catch (Exception e) {
          e.printStackTrace();
      }
  %>
</table>
</body>
</html>
